﻿#ifndef HEADSPACINGSHEETDIALOG_H
#define HEADSPACINGSHEETDIALOG_H

#include <QDialog>
#include "qmath.h"
#include <QString>
#include <algorithm>
#include <QLabel>
#include <QPushButton>
#include <bitset>
#include "mcheaddialog.h"
#include "setcontrolstyle.h"
#include "promptdialog.h"
#include "datafile/datafiledsr.h"
#include "sharedviews/fileselectdialog.h"
#include "sharedviews/promptdialog.h"
 

template<size_t N>
std::string to_1string(const std::bitset<N>& b)
{
    return b.template
        to_string<char, char_traits<char>, allocator<char> >();
}

namespace Ui {
class HeadSpacingSheetDialog;
}

class HeadSpacingSheetDialog : public QDialog
{
    Q_OBJECT

public:
    explicit HeadSpacingSheetDialog(QWidget *parent = 0);
    ~HeadSpacingSheetDialog();

private:
    Ui::HeadSpacingSheetDialog *ui;

private:
    s16 m_reType;//x、y类型
    int m_btnPerPage;//每页按钮数
    int m_curPages;//花样选择界面当前页数
    int m_pageNums;//总页数
    QList<MyButton*> m_sheetBtnList;//表格按钮个数
    QList<QLabel*> m_sheetHLabelList;//横向label
    QList<QLabel*> m_sheetVLabelList;//纵向label
    QList<u16> m_itemXList;//条目数
    QList<u16> m_itemYList;//条目数
    DsrHeadEx62 m_data;  //数据
    int m_dataNums; //总跨步数
    QString m_fileName;

public:
    void refreshPageUi();//刷新界面显示
    void setTypeLogo(QString tStyle);//设置类型图标
    void setMainTitle(QString str);//设置主title
    void setSubTitle(QString str);//设置副title

private slots:
    void on_buttonOk_clicked();
    void on_buttonCancel_clicked();
    void on_buttonPgDn_clicked();
    void on_buttonPgUp_clicked();

    void on_buttonParaExport_clicked();
    void on_buttonParaImport_clicked();

    QString intDiv10(int num); //返回整数除10之后保留1位小数的QString
    QString charToQString(char data);

public slots:
    void slotSheetBtnClicked();//表格中按钮被点击
    void setHeadData(DsrHeadEx62 data);
    DsrHeadEx62 getHeadData();
    //解析文件信息
    void initDsrFileInfo(QString fileName);
    void setStepNums(int dataNums);
    QString detectUsb();

private:
    void initWidget();
    void initControl();
    void initResolution();
    void initControlStyle();//初始化窗体控件样式

};

#endif // HEADSPACINGSHEETDIALOG_H
